motorcycles=["honda","yamaha","suzuki","ducati"]
print("原始列表：",motorcycles,"\n")
#too_expensive="yamaha"
#motorcycles.remove(too_expensive)
#print("不清楚需要删除的在哪个位置，但是知道要删除的是'yamaha':",motorcycles,"\n")
#print(too_expensive)
#motorcycles.pop()
#print(motorcycles)
#motorcycles.remove("honda")
#print(motorcycles)
too_expensive=motorcycles.remove("ducati")
print(too_expensive)
print(motorcycles)

print("练习题3.4-3.7")
guests=["zhangsan","lisi","wangmazi","shihao","xiaoyan"]
print("\n邀请人员名单如下：",guests)

print("\n很遗憾lisi无法赴约,将邀请李长寿来赴约\n")
guests[1]="lichangshou"
for guest in guests:
    print(f"亲爱的顾客,{guest},诚挚的邀请您今晚共进晚餐！")
    print("\n")
  
print("我找到了一张更大的桌，还想再邀请三位嘉宾:\n")
guests.insert(0,"lindong")
guests.insert(3,"lilin")
guests.append("xingtian")
for guest in guests:
	print(f"亲爱的顾客,{guest},诚挚的邀请您今晚共进晚餐！")
	print("\n")

print("新购买的餐桌不能及时送达，只能邀请两位嘉宾共进晚餐\n")
while len(guests)>2:
   poped_guests=guests.pop()
   print(f"亲爱的,{poped_guests},很遗憾，今天无法邀请您来共进晚餐了！")
   print("\n")

   for guest in guests:
       print(f"亲爱的顾客,{guest},你任然在受邀之列！")
       print("\n")
#删除最终的两位嘉宾
del guests[0:2]
print(f"最终的嘉宾名单:{guests}")
print("\n")


hdkh=[32,"sd","fd","rt"]
while len(hdkh)>0:
     del hdkh[0:]
     print(hdkh)


print("sort进行永久排序：\n")

cars=["bmw","audi","toyota","subaru"]
print("输出骑车名称列表",cars,"\n")
cars.sort()
print(f"\n将汽车按首字母排序,{cars}")

#cars.sort(reverse=True)
#print(f"\n将汽车按首字母倒序排序,{cars}")

cars.reverse()
print(f"\n将汽车按首字母倒序排序,{cars}")

print("sorted进行临时排序")

print("\n here is the original list:\n",cars)
print("\n here is sorted list:\n",sorted(cars))
print("\n here is the original list again:\n",cars,"\n")
print(cars[::-1],"\n")

print(str(cars).title(),"\n")
print(cars,"\n")

print("求列表cars的长度：",len(cars))
print(cars[0])

print("练习题3.8-3.10\n")

travel=["beijing","Guilin","xian","YunNan","qingdao"]

print("想去旅游的原始列表清单：",travel,"\n")
print(f"按字母顺序进行排序，且不修改原顺序：{sorted(travel,key=str.lower,reverse=False)}\n")
print("看原始列表清单顺序是否未变：",travel,"\n")
print(f"按字母顺序进行反向排序，且不修改原顺序：{sorted(travel,key=str.lower,reverse=True)}\n")
print("再次看原始列表清单顺序是否未变：",travel,"\n")

travel.reverse()
print("确认原始列表清单是否改变：",travel,"\n")
travel.reverse()
print("再次确认原始列表清单是否恢复原来顺序：",travel,"\n")

travel.sort(key=str.lower,reverse=False)
print(f"通过sort排序，核实原列表排列顺序是否改变：{travel}\n")
travel.sort(key=str.lower,reverse=True)
print(f"通过sort排序，核实原列表排列顺序是否改变：{travel}\n")

